package org.xteam.sled.semantic.exp;

public abstract class ExpBinary extends Exp {

	protected Exp left;
	protected Exp right;

	public ExpBinary(Exp left, Exp right) {
		this.left = left;
		this.right = right;
		left.setParent(this);
		right.setParent(this);
	}
	
	@Override
	public int hashCode() {
		return left.hashCode()<<1 ^ right.hashCode();
	}
	
	public Exp left() {
		return left;
	}
	
	public Exp right() {
		return right;
	}
	
	public void replace(Exp oldExp, Exp newExp) {
		if (oldExp.equals(left))
			left = newExp;
		else if (oldExp.equals(right))
			right = newExp;
	}

}
